<template>
  <a-spin :spinning="spinning">
    <div class="main">
      <a-card title="查看档案详情" :loading="loading">
        <template #extra>
          <a-button type="primary" @click="tocopy" :disabled="disabled" v-if="form.sccode">复制</a-button>
        </template>
        <div style="display:flex">
          <a-form-model :model="form" style="width:calc(100% - 300px)" labelAlign="right" :rules="rules" ref="ruleForm"
            :labelCol="{ span: 10 }" :wrapperCol="{ span: 14 }">
            <a-row>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">基础档案</h3>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品编号:</div>
                  <div class="right"> {{ form.sccode }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品大类:</div>
                  <div class="right"> {{ form.scdlValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品小类:</div>
                  <div class="right"> {{ form.scxlValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="!showProcess">
                <div class="line">
                  <div class="left">产品细分:</div>
                  <div class="right"> {{ form.scxflValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品名称:</div>
                  <div class="right"> {{ form.scname }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">厂家编号:</div>
                  <div class="right"> {{ form.sccshh }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">供应厂商:</div>
                  <div class="right"> {{ form.scsupName }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">放样周期:</div>
                  <div class="right"> {{ form.scvc1 }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">大货周期:</div>
                  <div class="right"> {{ form.scdhpricetype }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">对应上货季:</div>
                  <div class="right"> {{ form.scseasonValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">起订数量:</div>
                  <div class="right"> {{ form.scmoq }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">关联编号:</div>
                  <div class="right"> {{ form.screlation }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">纤维维度:</div>
                  <div class="right"> {{ form.scFiberDimension }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">关联类型:</div>
                  <div class="right"> {{ form.screlationtype }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">含油率:</div>
                  <div class="right"> {{ form.scContainOily }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">配套螺纹编号:</div>
                  <div class="right"> {{ form.scRibCode }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品备注:</div>
                  <div class="right"> {{ form.scmemo }}</div>
                </div>
              </a-col>
              <!-- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" :xxl="12">
                {{form.scmemo}}
                </a-col> -->
              <div v-if="showProcess">
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">加工属性</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <div class="line">
                    <div class="left">是否再加工:</div>
                    <div class="right">
                      <span v-if="form.scisprocess == 'Y'"> 是</span>
                      <span v-if="form.scisprocess == 'N'"> 否</span>
                    </div>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'Y'">
                  <div class="line">
                    <div class="left">加工类型:</div>
                    <div class="right"> {{ form.scprocesstypeValue }}</div>
                  </div>
                </a-col>

                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'Y'">
                  <div class="line">
                    <div class="left">底/面编号:</div>
                    <div class="right"> {{ form.sclowercode }}</div>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <div class="line">
                    <div class="left">底布名称:</div>
                    <div class="right"> {{ form.sclowername }}</div>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'N'">
                  <div class="line">
                    <div class="left">底布小类:</div>
                    <div class="right"> {{ form.sclowersmalltype }}</div>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <div class="line">
                    <div class="left">底布细分:</div>
                    <div class="right"> {{ form.lowerminismalltypeValue }}</div>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <div class="line">
                    <div class="left">其他底布:</div>
                    <div class="right"> {{ form.sclowerothers }}</div>
                  </div>
                </a-col>
              </div>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">产品规格</h3>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品成分:</div>
                  <div class="right"> {{ form.sccf }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">有效门幅:</div>
                  <div class="right"> {{ form.scmf }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">平方克重(g/㎡):</div>
                  <div class="right"> {{ form.scmlkz }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品规格:</div>
                  <div class="right"> {{ form.scspec }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">产品价格</h3>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品单价:</div>
                  <div class="right"> {{ form.scprice }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">标化单价:</div>
                  <div class="right"> {{ form.bhprice }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">核价成本:</div>
                  <div class="right"> {{ form.schj }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">大货单价:</div>
                  <div class="right"> {{ form.scdhprice }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">底布单价:</div>
                  <div class="right"> {{ form.scyhprice }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">小品牌价格:</div>
                  <div class="right"> {{ form.scprice1 }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">特殊单价:</div>
                  <div class="right"> {{ form.scsyn01 }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">价格单位:</div>
                  <div class="right"> {{ form.scpricetype }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" :xxl="12">
                <div class="line">
                  <div class="left">阶梯价格:</div>
                  <div class="right"> {{ form.scdhpricememo }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">关键指标</h3>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">合同缩率:</div>
                  <div class="right"> {{ form.scmlsl }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">排料缩率:</div>
                  <div class="right"> {{ form.scmlsl1 }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">扭曲率:</div>
                  <div class="right"> {{ form.sctwistrate }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">成衣洗涤:</div>
                  <div class="right"> {{ form.scgyValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品外观:</div>
                  <div class="right"> {{ form.scappearanceValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">布面效果:</div>
                  <div class="right"> {{ form.sceffectValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">面料特性:</div>
                  <div class="right"> {{ form.scqualityValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品工艺:</div>
                  <div class="right"> {{ form.scfjgyValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">排版要求:</div>
                  <div class="right"> {{ form.scshksValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">产品弹力:</div>
                  <div class="right"> {{ form.scelasticValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">硬挺度:</div>
                  <div class="right"> {{ form.scstiffnessValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">损耗率:</div>
                  <div class="right"> {{ form.scn1 }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">推广属性</h3>
                </div>
              </a-col>

              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">环保标签:</div>
                  <div class="right"> {{ form.scoriginarea }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">进口产地:</div>
                  <div class="right"> {{ form.scimportareaValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">原料产地:</div>
                  <div class="right"> {{ form.scenvironmentalValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">服用功能:</div>
                  <div class="right"> {{ form.scfzytValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">高档材料:</div>
                  <div class="right"> {{ form.scseniormaterialValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">材料等级:</div>
                  <div class="right"> {{ form.scmateriallevelValue }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="24" :xxl="24">
                <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                  <h3 style="color: #969799;">其他属性</h3>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">图案编号:</div>
                  <div class="right"> {{ form.scpiccode }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">图案名称:</div>
                  <div class="right"> {{ form.scpicName }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">商检成分:</div>
                  <div class="right"> {{ form.composition }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.sccode">
                <div class="line">
                  <div class="left">制单人:</div>
                  <div class="right"> {{ form.sccreator }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.sccode">
                <div class="line">
                  <div class="left">制单日期:</div>
                  <div class="right"> {{ form.updatedate }}</div>
                </div>
              </a-col>
              <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                <div class="line">
                  <div class="left">档存编号:</div>
                  <div class="right"> {{ form.scdesignbill }}</div>
                </div>
              </a-col>

            </a-row>


          </a-form-model>
          <div style="width:300px;padding: 35px 20px;">
            <img :src="form.schavpict" alt="form.schavpict" style="width:290px">
            <div style="width:290px">
              产品风险评估:{{ form.scriskassessment }}
            </div>
            <div style="width:290px;margin-top: 30px;">
              产品推广资料:{{ form.scpopularize }}
            </div>
            <div style="display:flex;width: 300px;margin-top: 30px;">是否推荐：
              <span v-if="form.scisrecommend == 'Y'">
                是
              </span>
              <span v-if="form.scisrecommend == 'N'">
                否
              </span>

            </div>
          </div>

        </div>
      </a-card>
      <a-card>
        <a-tabs :default-active-key="0" v-model="current" @change="changeTab">
          <a-tab-pane :key="0" tab="颜色">
          </a-tab-pane>
          <a-tab-pane :key="1" tab="产品缩率">
          </a-tab-pane>
          <a-tab-pane :key="2" tab="物料成分">
          </a-tab-pane>
        </a-tabs>
        <a-table bordered v-show="current == 0" :columns="cloumn1" :pagination="false" style="margin-top:20px"
          :data-source="colorList"></a-table>
        <a-table v-show="current == 1" bordered :columns="cloumn3" :pagination="false" style="margin-top:20px"
          :data-source="minifiList"></a-table>
        <a-table v-show="current == 2" bordered :columns="cloumn2" :pagination="false" style="margin-top:20px"
          :data-source="groupList"> </a-table>
        <div style="display: flex;justify-content: flex-end;">
          <a-pagination v-model="pageNum" :total="total" :item-render="itemRender" :show-total="total => `共 ${total} 条记录`"
            :page-size="pageSize" show-quick-jumper @change="onChange" />
        </div>
      </a-card>
    </div>
  </a-spin>
</template>
  
<script>
import color from './color.vue'
import minifi from './minifi.vue'
import group from './group.vue'
import JImageUpload from './upload/JImageUpload.vue'
import fileUpload from './upload/uploadfile.vue'
import fileUpload1 from './upload/uploadfile1.vue'
import fileUpload2 from './upload/uploadfile2.vue'
import globalData from '@/assets/js/common'
import { postAction } from '@/api/manage'
import { axios } from '@/utils/request'
import { seachSupply, getSampleInfo, getSampleColorList, getSampleMinifiList, getSampleGroupList, seachPattern, sampleUpdate, sampleAdd, saveMaterial, getDictChildList, getDetail, updateMaterial, uploadFiles, minifiList } from '@api/material/index'
const cloumn1 = [
  {
    title: '序号',
    dataIndex: 'mcsx'
  },
  {
    title: '销售色',
    dataIndex: 'mcid'
  },
  {
    title: '销售色名称',
    dataIndex: 'mcname'
  },
  {
    title: '季节',
    dataIndex: 'mcseasonValue'
  },
  {
    title: '印花色',
    dataIndex: 'mcvc4'
  },
  {
    title: '备注',
    dataIndex: 'mcmemo'
  },
]
const cloumn2 = [
  {
    title: '序号',
    dataIndex: 'rowno'
  },
  {
    title: '成分',
    dataIndex: 'sccfValue',
  },
  {
    title: '占比',
    dataIndex: 'sccfbl',
    scopedSlots: { customRender: 'sccfbl' }
  },
]
const cloumn3 = [
  {
    title: '序号',
    dataIndex: 'cmRowid'
  },
  {
    title: '面料要求',
    dataIndex: 'cmTypeValue',
  },
  {
    title: '经缩率%',
    dataIndex: 'cmLongitude',
    scopedSlots: { customRender: 'cmLongitude' }
  },
  {
    title: '纬缩率%',
    dataIndex: 'cmLatitude',
    scopedSlots: { customRender: 'cmLatitude' }

  },
]
export default {
  components: {
    color,
    minifi,
    group,
    JImageUpload,
    fileUpload,
    fileUpload1,
    fileUpload2
  },
  data() {
    return {
      cloumn1,
      cloumn2,
      cloumn3,
      sccode: '',
      patternCode: '',
      scdlList: [],
      scxlList: [],
      scxflList: [],
      scsupidList: [],
      scseasonList: [],
      scqualityList: [],
      scimportareaList: [],
      scgyList: [],
      appearanceList: [],
      effectList: [],
      elasticList: [],
      stiffnessList: [],
      environmentalList: [],
      seniormaterialList: [],
      materiallevelList: [],
      scfjgyList: [],
      scshksList: [],
      scfzytList: [],
      relationtypeList: [],
      processtypeList: [],
      lowercodeList: [],
      lowersmalltypeList: [],
      patternList: [],
      lowerminismallList: [],
      classifyMinimumList: [],
      putGoodsSeasonList: [],
      typeList: [],
      colorAttributeList: [],
      specialSuffixValueList: [],
      priceProgrammeList: [],
      supplyTypeList: [],
      spinning: false,
      taxRate: '',
      current: 0,
      urlKey: 'basemgt-material/',
      form: {
        flag3d: "",
        platformid: "",
        jobnumber: '',
        sampleClothGroupDTOList: [],
        sampleClothMatColorDTOList: [],
        sampleClothMinificationDTOList: [],
        scc130: "",
        scxfl: undefined,
        screlation: '',
        scmoq: '',
        screlationtype: undefined,
        scisprocess: undefined,
        scprocesstype: undefined,
        sclowercode: undefined,
        scappearance: undefined,
        sceffect: undefined,
        scelastic: undefined,
        scstiffness: undefined,
        scenvironmental: undefined,
        scseniormaterial: undefined,
        scmateriallevel: undefined,
        sclowersmalltype: undefined,
        scoriginarea: '',
        sctwistrate: '',
        sclowername: '',
        sclowerothers: '',
        scdhpricetype: '',
        scyhprice: '',
        sccf: "",
        sccjsh: "",
        sccode: "",
        sccreatdate: "",
        sccshh: "",
        sccw: "",
        scdesignbill: "",
        scdhprice: "",
        scdhpricememo: "",
        scdhpricetype: "",
        scdl: undefined,
        scfjgy: undefined,
        scfsfs: "",
        scfzyt: undefined,
        scgy: undefined,
        scgymain: "",
        schavpict: "",
        schj: '',
        scimportarea: undefined,
        scisrk: "",
        sckcsl: 0,
        bhprice: '',
        scmatertype1: "",
        scmatertype2: "",
        scmemo: "",
        scmf: "",
        scmlkz: "",
        scmlsl: "",
        scmlsl1: "",
        scn1: '',
        scname: "",
        lowerminismalltype: undefined,
        scpiccode: undefined,
        scpicName: '',
        scprice: '',
        scprice1: '',
        scpricetype: "",
        scquality: undefined,
        scseason: undefined,
        scshks: undefined,
        scsupid: undefined,
        scsyn01: "",
        scvc1: "",
        scxl: undefined,
        scpopularize: '',
        scriskassessment: '',
      },
      rules: {
        scdl: [{ required: true, message: '请选择产品大类', trigger: 'change' }],
        scxl: [{ required: true, message: '请选择产品小类', trigger: 'change' }],
        scname: [{ required: true, message: '请输入产品名称', trigger: 'change' }],
        scsupid: [{ required: true, message: '请选择供应厂商', trigger: 'change' }],
        scisprocess: [{ required: true, message: '请选择是否再加工', trigger: 'change' }],
        scprocesstype: [{ required: true, message: '请选择加工类型', trigger: 'change' }],
        sccf: [{ required: true, message: '请输入产品成分', trigger: 'change' }],
        scmf: [{ required: true, message: '请输入有效门幅', trigger: 'change' }],
        scmlkz: [{ required: true, message: '请输入平方克重', trigger: 'change' }],
        scgy: [{ required: true, message: '请选择成衣洗涤', trigger: 'change' }],
      },
      showProcess: false,
      colorList: [],
      minifiList: [],
      groupList: [],
      filePath1: [],
      fileList1: [],
      filePath2: [],
      filePath3: [],
      schavpict: [],
      total: 0,
      pageNum: 1,
      pageSize: 10,
      itemRender: (current, type, originalElement) => {
        if (type === 'prev') {
          return <a>上一页</a>
        } else if (type === 'next') {
          return <a>下一页</a>
        }
        return originalElement
      },
      priceList: [],
      supplyList: [],
      showSupply: false,
      showPrice: false,
      showCopy: false,
      loading: false,
      supplyDetail: {},
      supplyIndex: null,
      showPrint: false,
      showSelect: false,
      printType: '',
      priceProgramme: '',
      list: [],
      supplyCode: '',
      newLifePhotos: [],
      disabled: false,
      current: 0,
      ifChange: false
    }
  },
  watch: {
    // sccode(newVal, oldVal) {
    //   if (newVal && newVal !== oldVal) {
    //     this.loadAcc(newVal)
    //   }
    // },
  },
  created() { },
  computed: {
    jobNumber() {
      return this.$store.getters.userInfo.workNo || ''
    },
    userInfo() {
      return this.$store.getters.userInfo || null
    }
  },
  mounted() {
    this.loadData()
    if (this.$route.query.sccode) {
      this.sccode = this.$route.query.sccode
      this.$nextTick(() => {
        this.loadAcc(this.sccode)
        this.loadColor()
        // this.loadminifi()
        // this.loadgroup()
        // this.loadAccSpecs()
      })
    }
  },
  methods: {
    filterOption(input, option) {
      if (option && option.props && option.props.title) {
        return option.props.title === input || option.props.title.indexOf(input) !== -1
      } else {
        return true
      }
    },
    changeTab() {
      this.pageNum = 1
      if (this.current == 0) {
        this.loadColor()
      } else if (this.current == 1) {
        this.loadminifi()
      } else {
        this.loadgroup()
      }
    },
    onChange() {
      if (this.current == 0) {
        this.loadColor()
      } else if (this.current == 1) {
        this.loadminifi()
      } else {
        this.loadgroup()
      }
    },
    tocopy() {
      this.$router.replace({ path: '/material-file/material/add', query: { copycode: this.form.sccode } })
    },
    async getScsupidList(value) {
      const res = await seachSupply({ keyWord: value })
      if (res.code == 200) {
        this.scsupidList = res.data
      } else {
        if (res.msg) {
          this.$message.error(res.msg)
        } else {
          this.$message.error('获取供应商列表失败！')
        }
      }
    },
    async getPatternList(value) {
      const res = await seachPattern({ keyWord: value })
      if (res.code == 200) {
        this.patternList = res.data
      } else {
        if (res.msg) {
          this.$message.error(res.msg)
        } else {
          this.$message.error('获取图案列表失败！')
        }
      }
    },
    async loadLowercode() {
      const res = await getSampleInfo({ sccode: this.form.sclowercode })
      if (res.code == 200) {
        this.form.sclowername = res.data.scname
        this.form.sclowersmalltype = res.data.scxl
        this.changeLowersmalltype()
      } else {
        if (res.msg) {
          this.$message.error(res.msg)
        } else {
          this.$message.error('查找底布失败！')
        }
      }
    },
    changeIsprocess() {
      this.form.scprocesstype = undefined
      this.form.sclowercode = ''
      this.form.sclowername = ''
      this.form.sclowersmalltype = undefined
    },
    loadData() {
      this.getDictChildList('PRODUCT_BIGTYPE', 'scdlList')
      this.getScsupidList()
      this.getPatternList()
    },
    async getDictChildList(name, list, id) {
      if (!this[list].length || (this[list].length && id)) {
        const params = {
          name: name,
          parentId: id
        }
        try {
          const res = await getDictChildList(params)
          if (res.code == 200) {
            this[list] = res.data
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('获取数据字典失败！')
            }
          }
        } catch (error) {
          this.$message.error('获取数据字典失败！')
        }
      }
      if (this.processtypeList.length) {
        this.showProcess = true
      } else {
        this.showProcess = false
      }
      if (name == 'PRODUCT_BIGTYPE' && this.form.scdl && this.scdlList.length) {
        this.scdlList.map(item => {
          if (item.code == this.form.scdl) {
            this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
          }
        })
      }
      if (name == 'PRODUCT_SMALLTYPE' && this.form.scxl && this.scxlList.length) {
        this.scxlList.map(item => {
          if (item.code == this.form.scxl) {
            this.getDictChildList('PRODUCT_MINISMALLTYP', 'scxflList', item.id)
            this.getDictChildList('PRODUCT_TECHNOLOGY', 'processtypeList', item.id)
          }
        })
      }
    },
    changeBig() {
      this.form.scxl = undefined
      if (this.scdlList) {
        this.scdlList.map(item => {
          if (item.code == this.form.scdl) {
            this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
          }
        })
      }
    },
    changeSmall() {
      this.form.scxfl = undefined
      this.form.scprocesstype = undefined
      this.processtypeList = []
      if (this.scxlList) {
        this.scxlList.map(item => {
          if (item.code == this.form.scxl) {
            this.getDictChildList('PRODUCT_MINISMALLTYP', 'scxflList', item.id)
            this.getDictChildList('PRODUCT_TECHNOLOGY', 'processtypeList', item.id)
          }
        })
      }
    },
    changeLowersmalltype() {
      this.form.lowerminismalltype = undefined
      if (this.scxlList) {
        this.scxlList.map(item => {
          if (item.code == this.form.sclowersmalltype) {
            this.getDictChildList('PRODUCT_MINISMALLTYP', 'lowerminismallList', item.id)
          }
        })
      }
    },
    changeSeniormaterial() {
      this.form.scmateriallevel = undefined
      if (this.seniormaterialList) {
        this.seniormaterialList.map(item => {
          if (item.code == this.form.scseniormaterial) {
            this.getDictChildList('PRODUCT_MATERIALLEVEL', 'materiallevelList', item.id)
          }
        })
      }
    },
    changePattern() {
      this.patternCode = this.form.scpiccode
      this.form.scpicName = ''
      console.log(this.patternList);
      if (this.patternList) {
        this.patternList.map(item => {
          if (item.patternCode == this.form.scpiccode) {
            this.form.scpicName = item.patternName
          }
        })
      }
    },
    getLittle() {

    },
    getSmall() {
      if (this.form.classifyBig) {
        this.classifyBigList.map(item => {
          if (item.code == this.form.classifyBig) {
            this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
          }
        })
      }
    },
    getMin() {
      this.getDictChildList('CLASSIFY_MINIMUM', 'classifyMinimumList')
    },
    getModel(name, list) {
      if (this.form.scxl) {
        this.scxlList.map(item => {
          if (item.code == this.form.scxl) {
            this.getDictChildList(name, list, item.id)
          }
        })
      }
    },
    handleCancel() {
      this.showSelect = false
    },
    handleOk() {
      if (this.printType) {
        this.showSelect = false
        this.showPrint = true
      } else {
        this.$message.warning('请先选择打印类型！')
      }
    },
    getUploadParams() {
      return { ...globalData.uploadParams }
    },
    fileChange(list) {
      if (list.length) {
        this.form.schavpict = list[0].url
      } else {
        this.form.schavpict = ''
      }
      this.newLifePhotos = list

    },
    fileChange1(list) {
      this.fileList1 = list
      console.log(this.fileList1);
    },
    fileChange2(list) {
      this.fileList2 = list
    },
    fileChange3(list) {
      this.fileList3 = list
    },
    async saveFile(type) {
      const formData = new FormData()
      if (type == 1) {
        this.fileList1.forEach((file) => {
          formData.append(`files`, file.originFileObj);
        });
      } else if (type == 2) {
        this.fileList2.forEach((file) => {
          formData.append(`files`, file.originFileObj);
        });
      } else {
        this.fileList3.forEach((file) => {
          formData.append(`files`, file.originFileObj);
        });
      }
      formData.append('sccode', this.sccode)
      formData.append('type', type)
      const apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot";
      axios({
        url: apiBaseUrl + '/api/gateway/basemgt-material/sample-upload-file/uploadFiles',
        method: 'post',
        data: formData,
        contentType: false,
        cache: false,
        processData: false,//用于对data参数进行序列化处理 这里必须false
        // headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq' }
      }).then(res => {
        if (res.code == 200) {
          this.$message.success('保存成功')
        } else {
          this.$message.warning(res.msg || '操作失败')
        }
        this.loading = false
      })

    },
    changeColor() {
      this.loadColor()
    },
    changeminifi() {
      this.loadminifi()
    },
    changegroup() {
      this.loadgroup()
    },

    changeSupply(supplyList) {
      this.form.accSupplyList = supplyList
      if (this.form.priceProgramme == 'ZIPPER') {
        this.ifChange = true
      }
    },
    async loadColor() {
      const params = {
        sccode: this.sccode,
        size: this.pageSize,
        pageNo: this.pageNum
      }
      try {
        const res = await getSampleColorList(params)
        if (res.code == 200) {
          this.colorList = res.data.records
          this.total = res.data.total
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取颜色列表失败！')
          }
        }
      } catch (error) {
        this.$message.error('获取颜色列表失败！')
      }
    },
    async loadminifi() {
      const params = {
        sccode: this.sccode,
        size: this.pageSize,
        pageNo: this.pageNum
      }
      try {
        const res = await getSampleMinifiList(params)
        if (res.code == 200) {
          this.minifiList = res.data.records
          this.total = res.data.total
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取缩率列表失败！')
          }
        }
      } catch (error) {
        this.$message.error('获取缩率列表失败！')
      }
    },
    async loadgroup() {
      // this.form.sccf = ''
      const params = {
        sccode: this.sccode,
        size: this.pageSize,
        pageNo: this.pageNum
      }
      try {
        const res = await getSampleGroupList(params)
        if (res.code == 200) {
          this.groupList = res.data.records
          // if(this.groupList.length){
          //   this.form.sccf = this.groupList[0].sccfValue
          // }   
          this.total = res.data.total
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取成分列表失败！')
          }
        }
      } catch (error) {
        this.$message.error('获取成分列表失败！')
      }
    },
    onSubmit() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.save()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    async save() {
      this.spinning = true
      try {
        this.form.jobnumber = this.jobNumber
        this.form.sccreator = this.userInfo.realname
        let res = this.form.sccode ? await sampleUpdate(this.form) : await sampleAdd(this.form)
        if (res.code == 200) {
          this.$message.success('保存成功！')
          if (!this.form.sccode) {
            this.form.sccode = res.data.msg
          }
          this.$nextTick(() => {
            this.loadAcc(this.form.sccode)
          })
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('保存失败！')
          }

        } this.spinning = false
      } catch (error) {
        this.spinning = false

        this.$message.error('保存失败！')
      }
    },
    async loadAcc(sccode) {
      this.loading = true
      this.schavpict = []
      try {
        const res = await getSampleInfo({ sccode: sccode })
        if (res.code == 200) {
          this.form = res.data
          if (res.data.schavpict) {
            this.schavpict.push(res.data.schavpict)
          }
          if (res.data.scpiccode) {
            this.changePattern()
          }
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取列表详情失败！')
          }
          this.disabled = true
        }
        this.loading = false
      } catch (error) {
        this.loading = false
        this.disabled = true
      }
    },
    sync(values) {
      this.supplyList.map(item => {
        if (item.supplyCode == values.supplyCode) {
          item.defaultStatus = 1
          this.accPriceList = item.accPriceList
        } else {
          item.defaultStatus = 0
        }
      })
    },
    closePrice(supplyCode, list) {
      this.showPrice = false
      if (list) {
        this.supplyList.map(item => {
          if (item.supplyCode == supplyCode) {
            item.accPriceList = list
            if (item.defaultStatus == 1) {
              this.accPriceList = list
            }
          }
        })
        this.form.accSupplyList = this.supplyList
      }
    }
  }
}
</script>
<style>
.tableHiddle {
  display: none;
}

.tableShow {
  display: revert;
}
</style>
<style scoped>
.line {
  height: 40px;
  line-height: 40px;
  display: flex
}

.left {
  width: 100px;
  text-align: right;
  color:rgb(0 0 0 / 85%)
}

.right {
  margin-left: 5px;
}
</style>